# Setup fzf
if type -q fzf
  set -l fd_bin ""
  set -Ux FZF_DEFAULT_OPTS "\
    --color=bg+:#313244,bg:#1e1e2e,spinner:#f5e0dc,hl:#f38ba8 \
    --color=fg:#cdd6f4,header:#f38ba8,info:#cba6f7,pointer:#f5e0dc \
    --color=marker:#f5e0dc,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8"

  if type -q fd
    set fd_bin fd
  else if type -q fdfind # fdfind on debian based
    set fd_bin fdfind
  end

  if test $fd_bin != ""
    set -Ux FZF_DEFAULT_COMMAND "$fd_bin --type f --strip-cwd-prefix --hidden --exclude .git --exclude node_modules"
    set -Ux FZF_CTRL_T_COMAND "$FZF_DEFAULT_COMMAND"
  end

  if type -q bat
    set -Ux FZF_CTRL_T_OPTS "
      --preview 'bat -n --color=always {}'
      --bind 'ctrl-/:change-preview-window(down|hidden|)'
    "
  end
end

# Setup fish fzf plugin
if type -q fzf_configure_bindings
  fzf_configure_bindings --history=\e\cr --directory=\e\cf --git_status=\e\cs --git_log=\e\cl --process=\e\cp --variables=\e\cv
end
